package com.sunfeng.a04;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @Author : 孙峰
 * @Description:
 * @Date : 2022/4/8  14:15
 */
@Slf4j
public class Bean01 {
    private Bean02 bean02;

    @Autowired
    public void setBean02(Bean02 bean02) {
        log.debug("@Autowired 生效{}",bean02);
        this.bean02 = bean02;
    }

    private Bean03 bean03;

    @Resource
    public void setBean03(Bean03 bean03) {
        log.debug("@Resource 生效 {}",bean03);
        this.bean03 = bean03;
    }
    private String home;

    @Autowired
    public void setHome(@Value("${JAVA_HOME}") String home) {

        log.debug("@Value 生效 {}",home);
        this.home = home;
    }

    @PostConstruct
    public  void  init(){
      log.debug("@PostConstruct 生效~~" );
    }
    @PreDestroy
    public  void destroy(){
        log.debug("@PreDestroy 生效~~" );
    }

    @Override
    public String toString() {
        return "Bean01{" +
                "bean02=" + bean02 +
                ", bean03=" + bean03 +
                ", home='" + home + '\'' +
                '}';
    }
}
